const userDao = require('../dao/userDao'),
log = require('../util/log'),
svc = require('../util/service');

module.exports = (req, res) =>
svc.handlePost(req, res, (reqJSON, resolve) => {
	var un = reqJSON.username,
	pd = reqJSON.password;
	userDao.findByUsernamePassword(un, pd, user => {
		if (user == null)
			resolve({
				result : 0
			});
		else {
			req.session.user = user;
			resolve({
				result : 1
			})
		}
	})
})
